{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}/Users/fcoell/Dropbox/PATSTAT/DATA/../logs/Patentee_type.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}15 Apr 2020, 16:11:40
{txt}
{com}. di "Patentee type, mean and median Delta_K by type  - Initial and final sample"
{res}Patentee type, mean and median Delta_K by type  - Initial and final sample
{txt}
{com}. 
. use $tmp/samples, clear
{txt}
{com}. gen sector = "Firm" if firm == 1
{txt}(1,899,963 missing values generated)

{com}. replace sector = "Individual" if individual == 1
{txt}variable {bf}sector{sf} was {bf}{res}str4{sf}{txt} now {bf}{res}str10{sf}
{txt}(1,695,419 real changes made)

{com}. replace sector = "Other sector" if other_sector == 1
{txt}variable {bf}sector{sf} was {bf}{res}str10{sf}{txt} now {bf}{res}str12{sf}
{txt}(87,722 real changes made)

{com}. replace sector = "Unknown" if unknown_sector == 1
{txt}(116,822 real changes made)

{com}. save $tmp/tmpsector, replace
{txt}file /tmp/tmpsector.dta saved

{com}. 
. // Share of firms by sector in raw, initial and sample
. use $tmp/tmpsector, clear
{txt}
{com}. foreach v of varlist *sample {c -(}
{txt}  2{com}.         di "`v'"
{txt}  3{com}.         use $tmp/tmpsector, clear
{txt}  4{com}.         keep if `v' == 1
{txt}  5{com}.         contract hrm_l2_id sector
{txt}  6{com}.         tab sector
{txt}  7{com}. {c )-}
raw_sample
{txt}(40,197 observations deleted)

      sector {c |}      Freq.     Percent        Cum.
{hline 13}{c +}{hline 35}
        Firm {c |}{res}    356,279       33.83       33.83
{txt}  Individual {c |}{res}    575,973       54.69       88.52
{txt}Other sector {c |}{res}     33,703        3.20       91.72
{txt}     Unknown {c |}{res}     87,246        8.28      100.00
{txt}{hline 13}{c +}{hline 35}
       Total {c |}{res}  1,053,201      100.00
initial_sample
{txt}(824,696 observations deleted)

      sector {c |}      Freq.     Percent        Cum.
{hline 13}{c +}{hline 35}
        Firm {c |}{res}    297,266       38.93       38.93
{txt}  Individual {c |}{res}    412,438       54.01       92.94
{txt}Other sector {c |}{res}     13,076        1.71       94.66
{txt}     Unknown {c |}{res}     40,801        5.34      100.00
{txt}{hline 13}{c +}{hline 35}
       Total {c |}{res}    763,581      100.00
final_sample
{txt}(2,834,290 observations deleted)

      sector {c |}      Freq.     Percent        Cum.
{hline 13}{c +}{hline 35}
        Firm {c |}{res}     23,351       56.87       56.87
{txt}  Individual {c |}{res}     16,299       39.70       96.57
{txt}Other sector {c |}{res}      1,028        2.50       99.07
{txt}     Unknown {c |}{res}        380        0.93      100.00
{txt}{hline 13}{c +}{hline 35}
       Total {c |}{res}     41,058      100.00
{txt}
{com}. 
. // Mean and median Delta_K, across firms by sector, for initial and final sample
. /* Note: Delta_K can be 0 in final sample */
. use $tmp/tmpsector, clear
{txt}
{com}. foreach v of varlist *sample {c -(}
{txt}  2{com}.         di "`v'"
{txt}  3{com}.         use $tmp/tmpsector, clear
{txt}  4{com}.         keep if `v' == 1
{txt}  5{com}.         keep if inrange(y, 1992, 2000)
{txt}  6{com}.         collapse (sum) p, by(sector hrm_l2_id)
{txt}  7{com}.         collapse (mean) p (median) pmed = p, by(sector)
{txt}  8{com}.         list
{txt}  9{com}. {c )-}
raw_sample
{txt}(40,197 observations deleted)
(1,287,333 observations deleted)

     {c TLC}{hline 14}{c -}{hline 9}{c -}{hline 6}{c TRC}
     {c |} {res}      sector         p   pmed {txt}{c |}
     {c LT}{hline 14}{c -}{hline 9}{c -}{hline 6}{c RT}
  1. {c |} {res}        Firm   8.38165      1 {txt}{c |}
  2. {c |} {res}  Individual   1.69907      1 {txt}{c |}
  3. {c |} {res}Other sector   4.60653      1 {txt}{c |}
  4. {c |} {res}     Unknown   1.66897      1 {txt}{c |}
     {c BLC}{hline 14}{c -}{hline 9}{c -}{hline 6}{c BRC}
initial_sample
(824,696 observations deleted)
(920,918 observations deleted)

     {c TLC}{hline 14}{c -}{hline 9}{c -}{hline 6}{c TRC}
     {c |} {res}      sector         p   pmed {txt}{c |}
     {c LT}{hline 14}{c -}{hline 9}{c -}{hline 6}{c RT}
  1. {c |} {res}        Firm   9.56881      1 {txt}{c |}
  2. {c |} {res}  Individual   1.55599      1 {txt}{c |}
  3. {c |} {res}Other sector   7.61074      1 {txt}{c |}
  4. {c |} {res}     Unknown   1.44131      1 {txt}{c |}
     {c BLC}{hline 14}{c -}{hline 9}{c -}{hline 6}{c BRC}
final_sample
(2,834,290 observations deleted)
(123,201 observations deleted)

     {c TLC}{hline 14}{c -}{hline 9}{c -}{hline 6}{c TRC}
     {c |} {res}      sector         p   pmed {txt}{c |}
     {c LT}{hline 14}{c -}{hline 9}{c -}{hline 6}{c RT}
  1. {c |} {res}        Firm   29.6722      3 {txt}{c |}
  2. {c |} {res}  Individual    2.1996      1 {txt}{c |}
  3. {c |} {res}Other sector   24.9656      3 {txt}{c |}
  4. {c |} {res}     Unknown   4.42025      1 {txt}{c |}
     {c BLC}{hline 14}{c -}{hline 9}{c -}{hline 6}{c BRC}

{com}. 
. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}/Users/fcoell/Dropbox/PATSTAT/DATA/../logs/Patentee_type.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}15 Apr 2020, 16:11:56
{txt}{.-}
{smcl}
{txt}{sf}{ul off}